package Ticket;

import java.util.Calendar;

public class Ticket {
    private final String ID_src;//客户端的ID
    private final String ID_dst;
    private Calendar TS;
    private final int lifetime;
    private final String ADC;
    private final String key;

    public enum pos{
        ID_src,ID_dst,lifetime,TS,ADC,key
    }

    public Ticket(String ID_src,String ID_dst,int lifetime,String ADC,String key)
    {
        this.ID_dst=ID_dst;
        this.ID_src=ID_src;
        this.TS=Calendar.getInstance();
        this.lifetime=lifetime;
        this.ADC=ADC;
        this.key=key;
    }

    public void setTS(Calendar c)
    {
        TS=c;
    }
    public String getID_src()
    {
        return ID_src;
    }
    public String getKey(){return key;}
    public String getADC(){return ADC;}
    public String toStr() {
        String c = "-";
        String s_time = "";
        if (TS.get(Calendar.DATE) < 10) {
            s_time = s_time + "0" + TS.get(Calendar.DATE);

        } else {
            s_time = s_time + TS.get(Calendar.DATE);
        }
        if (TS.get(Calendar.HOUR) < 10) {
            s_time = s_time + "0" + TS.get(Calendar.HOUR);
        } else {
            s_time = s_time + TS.get(Calendar.HOUR);
        }
        if (TS.get(Calendar.MINUTE) < 10) {
            s_time = s_time + "0" + TS.get(Calendar.MINUTE);
        } else {
            s_time = s_time + TS.get(Calendar.MINUTE);
        }
        return this.ID_src + c + ID_dst + c + lifetime + c + s_time + c + ADC + c + key;
    }
    public String getID_dst(){return ID_dst;}
    public int getLifetime() {
        return lifetime;
    }



}
